#-----------------------------------------------------------------------------
class Guid:
    def __init__(self, id, ver):
        self.id_ = id
        self.ver_ = int(ver)

    def __str__(self):
        return self.to_raw()

    def __repr__(self):
        return '<Guid %s.%s>' % (self.id_, self.ver_)

    def __cmp__(self, other):
        return cmp(self.as_tuple(), other.as_tuple())

    def id(self):
        return self.id_

    def ver(self):
        return int(self.ver_)

    def as_tuple(self):
        return (self.id_, self.ver_)

    def to_raw(self):
        return '%s:%s' % (self.id_, self.ver_)

#-----------------------------------------------------------------------------
def from_raw(raw):
    i, v = raw.split(':')
    return Guid(i,v)

#-----------------------------------------------------------------------------
#
# Module constants
#
UNSET = Guid('unset', -1)
